package com.projects.android.dto;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

public class UsersDTO {
	private String ID;
	private String Name;
	private String Phone;
	private String Address;
	private String UserName;
	private String Password;
	private String Email;
	private boolean IsLockedOut;
	private ArrayList<OrdersDTO> Orders;
	
	public void initObject(JSONObject data){
		try {
			ID = data.getString("ID");
			Name = data.getString("Name");
			Phone = data.getString("Phone");
			Address = data.getString("Address");
			UserName = data.getString("UserName");
			Password = data.getString("Password");
			Email = data.getString("Email");
			IsLockedOut = Boolean.valueOf(data.getString("IsLockedOut"));
			Orders = new ArrayList<OrdersDTO>();
			JSONArray arrData = new JSONArray(data.getString("Orders"));
			// Loop for all reveived objects
			for (int i = 0; i < arrData.length(); i++) {
				JSONObject dataChild = (JSONObject) arrData.get(i);
				OrdersDTO dto = new OrdersDTO();
				dto.initObject(dataChild);
				Orders.add(dto);
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			Log.e("Init CityDTO", e.toString());
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			Log.e("Init CityDTO", e.toString());
		}
	}
	
	public String getID() {
		return ID;
	}
	public void setID(String iD) {
		ID = iD;
	}
	public String getName() {
		return Name;
	}
	public void setName(String name) {
		Name = name;
	}
	public String getPhone() {
		return Phone;
	}
	public void setPhone(String phone) {
		Phone = phone;
	}
	public String getUserName() {
		return UserName;
	}
	public void setUserName(String userName) {
		UserName = userName;
	}
	public String getPassword() {
		return Password;
	}
	public void setPassword(String password) {
		Password = password;
	}
	public String getEmail() {
		return Email;
	}
	public void setEmail(String email) {
		Email = email;
	}
	public boolean getIsLockedOut() {
		return IsLockedOut;
	}
	public void setIsLockedOut(boolean isLockedOut) {
		IsLockedOut = isLockedOut;
	}
	public ArrayList<OrdersDTO> getOrders() {
		return Orders;
	}
	public void setOrders(ArrayList<OrdersDTO> orders) {
		Orders = orders;
	}

	public String getAddress() {
		return Address;
	}

	public void setAddress(String address) {
		Address = address;
	}
}
